package com.ysd.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ysd.entity.Modules;
import com.ysd.mapper.ModulesMapper;
import com.ysd.service.ModulesService;
import com.ysd.utils.BuildTree;

@Service
public class ModulesServiceImpl implements ModulesService {
	
	@Autowired
	ModulesMapper mm;
	
	@Override
	public List<Modules> findTree() {
		BuildTree buildTree = new BuildTree();
		// 获取数据list
		List<Modules> treeNodes = mm.selectTree();
		List<Modules> list = buildTree.buildTree(treeNodes);
		return list;
	}

	@Override
	public int insertTree(Modules modules) {
		return mm.addTree(modules);
	}

	@Override
	public int modifyTree(Modules modules) {
		return mm.updateTree(modules);
	}

	@Override
	public Modules findName(Modules modules) {
		return mm.getName(modules);
	}

	@Override
	public List<Modules> findParentId(Modules modules) {
		return mm.getParentId(modules);
	}

	@Override
	public int cutTree(int id) {
		return mm.delTree(id);
	}

}
